<?php

namespace App\Admin\Exceptions;

use App\Admin\Traits\ReponseJson;
use Exception;
use Illuminate\Http\Request;

class EventException extends Exception
{
    use ReponseJson;

    public function __construct($message = '', $code = 500)
    {
        $this->code    = $code;
        $this->message = $message;
    }

    public function render(Request $request)
    {
        if ($request->expectsJson()) {
            return $this->failure($this->message, [], $this->code);
        }
        return view('error', ['code' => $this->code]);
    }
}
